

package org.koyabr.webx.demo.danmaku.dal.dao.ibatis;


import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.koyabr.webx.demo.danmaku.dal.dao.MulToMulDao;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

public class IbatisMulToMulDao extends SqlMapClientDaoSupport implements MulToMulDao {
    public void insertFollow(String followingName, String followedName){
    	
		HashMap<String, String> map = new HashMap<String, String>();
		map.put("followingName", followingName);
		map.put("followedName", followedName);
		
    	getSqlMapClientTemplate().insert("insertFollow", map);
    }

    public void insertWatch(String username, String postId){

		HashMap<String, String> map = new HashMap<String, String>();
		map.put("username", username);
		map.put("postId", postId);
		
    	getSqlMapClientTemplate().insert("insertWatch", map);
    }

    public void insertLike(String username, String postId){
    	
		HashMap<String, String> map = new HashMap<String, String>();
		map.put("username", username);
		map.put("postId", postId);
		
    	getSqlMapClientTemplate().insert("insertLike", map);
    }

    public void insertFavor(String username, String postId){
    	
		HashMap<String, String> map = new HashMap<String, String>();
		map.put("username", username);
		map.put("postId", postId);
		
    	getSqlMapClientTemplate().insert("insertFavor", map);
    }

    

    public void deleteFollow(String followingName, String followedName){
    	
		HashMap<String, String> map = new HashMap<String, String>();
		map.put("followingName", followingName);
		map.put("followedName", followedName);
		
    	getSqlMapClientTemplate().delete("deleteFollow", map);
    }

    public void deleteWatch(String username, String postId){
    	
		HashMap<String, String> map = new HashMap<String, String>();
		map.put("username", username);
		map.put("postId", postId);
		
    	getSqlMapClientTemplate().delete("deleteWatch", map);
    }

    public void deleteLike(String username, String postId){
    	
		HashMap<String, String> map = new HashMap<String, String>();
		map.put("username", username);
		map.put("postId", postId);
		
    	getSqlMapClientTemplate().delete("deleteLike", map);
    }

    public void deleteFavor(String username, String postId){
    	
		HashMap<String, String> map = new HashMap<String, String>();
		map.put("username", username);
		map.put("postId", postId);
		
    	getSqlMapClientTemplate().delete("deleteFavor", map);
    }


    @SuppressWarnings("unchecked")
    public Map<String, String> getFollow(String followingName, String followedName){
		HashMap<String, String> map = new HashMap<String, String>();
		map.put("followingName", followingName);
		map.put("followedName", followedName);
		
    	return (Map<String, String>)getSqlMapClientTemplate().queryForObject("getFollow", map);
    }

    @SuppressWarnings("unchecked")
    public Map<String, String> getWatch(String username, String postId){
		HashMap<String, String> map = new HashMap<String, String>();
		map.put("username", username);
		map.put("postId", postId);
		
    	return (Map<String, String>)getSqlMapClientTemplate().queryForObject("getWatch", map);
    }

    @SuppressWarnings("unchecked")
    public Map<String, String> getLike(String username, String postId){
		HashMap<String, String> map = new HashMap<String, String>();
		map.put("username", username);
		map.put("postId", postId);
		
    	return (Map<String, String>)getSqlMapClientTemplate().queryForObject("getLike", map);
    }

    @SuppressWarnings("unchecked")
    public Map<String, String> getFavor(String username, String postId){
		HashMap<String, String> map = new HashMap<String, String>();
		map.put("username", username);
		map.put("postId", postId);
		
    	return (Map<String, String>)getSqlMapClientTemplate().queryForObject("getFavor", map);
    }

	
    @SuppressWarnings("unchecked")
    public List<Map<String, String>> getAllFollow(String myName){
    	return (List<Map<String, String>>)getSqlMapClientTemplate().queryForObject("getAllFollow", myName);
    }
    
    @SuppressWarnings("unchecked")
    public List<Map<String, String>> getAllFan(String myName){
    	return (List<Map<String, String>>)getSqlMapClientTemplate().queryForObject("getAllFan", myName);
    }
    
    @SuppressWarnings("unchecked")
    public List<Map<String, String>> getAllWatchPost(String username){
    	return (List<Map<String, String>>)getSqlMapClientTemplate().queryForObject("getAllWacth", username);
    }
    
    @SuppressWarnings("unchecked")
    public List<Map<String, String>> getAllWatchUser(String postId){
    	return (List<Map<String, String>>)getSqlMapClientTemplate().queryForObject("getAllWacth", postId);
    }

    @SuppressWarnings("unchecked")
    public List<Map<String, String>> getAllLikePost(String username){
    	return (List<Map<String, String>>)getSqlMapClientTemplate().queryForObject("getAllLike", username);
    }
    
    @SuppressWarnings("unchecked")
    public List<Map<String, String>> getAllLikeUser(String postId){
    	return (List<Map<String, String>>)getSqlMapClientTemplate().queryForObject("getAllLike", postId);
    }

    @SuppressWarnings("unchecked")
    public List<Map<String, String>> getAllFavorPost(String username){
    	return (List<Map<String, String>>)getSqlMapClientTemplate().queryForObject("getAllFavor", username);
    }
    
    @SuppressWarnings("unchecked")
    public List<Map<String, String>> getAllFavorUser(String postId){
    	return (List<Map<String, String>>)getSqlMapClientTemplate().queryForObject("getAllFavor", postId);
    }
}
